<template>
  <div> 软件分类管理 </div>
  <div>
    <!-- {{ list }} -->

    <el-table :data="list">
      <el-table-column prop="tname" label="名称"></el-table-column>
      <el-table-column prop="intro" label="简介"></el-table-column>
      <el-table-column label="操作" width="100">
        <template #default="scope">
          <el-button type="success" @click="selectInfo(scope.row)"
            >选择</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <PageComp :page="page" @dochange="query"></PageComp>
  </div>
</template>
<script setup>
import { ref } from 'vue';
import { Api } from '../script/Api';
import PageComp from './PageComp.vue';
import { ElMessage } from 'element-plus';
const emits = defineEmits(['info-selected']);

const selectInfo = (info) => {
  console.log('选中的信息：', info);
  // 广播事件，并传出选中的信息
  emits('info-selected', info);
};

const page = ref({
  pageSize: 5,
  pageNumber: 1,
});

const queryInfo = ref({ tname: '' });

const list = ref([]);

const query = () => {
  Api.get(
    `/crud/softwaretype/${page.value.pageSize}/${page.value.pageNumber}`,
    queryInfo.value,
    (data) => {
      if (data.success) {
        list.value = data.data.data;
        page.value = data.data.pageBean;
      } else {
        ElMessage.error(data.message);
      }
    }
  );
};

query();
</script>
<style scoped></style>
